<?

/*
*
*   Excalibur Content Management System
*   Copyright © 2008 Egor "Sontan" Kuryanovich
*
*   Based on Explay Engine v2.0 by Golovdinov Alexander
*
*   Official site: www.excms.ru
*   Contact e-mail: support@excms.ru
*
*   GNU General Public License original source:
*   http://www.gnu.org/licenses/gpl-3.0.html
*
*/

if (!defined("DB_PEREFIX")) exit;

/* WTF? Not working in MySql 4*/ 
$get = $db->query ("SELECT art_id, art_category, art_header, art_author, art_rating, cat.cat_header, usr.user_name FROM ".DB_PEREFIX."_articles AS art
		LEFT JOIN (SELECT cat_name, cat_header FROM ".DB_PEREFIX."_art_category) AS cat ON art.art_category = cat.cat_name
		LEFT JOIN (SELECT user_id, user_name FROM ".DB_PEREFIX."_users) AS usr ON art.art_id = usr.user_id
		WHERE art_publik = 'yes' AND art_rating > -3 AND art_visible = 'on' ORDER BY art_id DESC LIMIT 0,10");

	/*
$get = $db->query ("
SELECT art_id, art_category, art_header, art_author, art_rating, cat.cat_header, usr.user_name, usr.user_id, cat_name, cat_header
FROM ".DB_PEREFIX."_articles AS art, ".DB_PEREFIX."_art_category AS cat, ".DB_PEREFIX."_users AS usr
WHERE art.art_publik = 'yes' 
	AND art.art_rating > -3 
	AND art.art_visible = 'on' 
	AND art.art_category = cat.cat_name 
	AND art.art_id = usr.user_id
ORDER BY art_id DESC LIMIT 0,10");		
*/

$list = '';
	
while (list ($id, $cat, $title, $uid, $rating, $cat_title, $uname) = $db->fetch_row ($get)) 
{
	$template->set_var ('{ART_ID}', $id);
	$template->set_var ('{ART_HEADER}', $title);
	$template->set_var ('{BLOG_NAME}', $cat);
	$template->set_var ('{BLOG_HEADER}', $cat_title);
	$template->set_var ('{AUTHOR_ID}', $uid);
	$template->set_var ('{AUTHOR_NAME}', $uname);
	$template->set_var ('{RATING}', $rating);
	
	$list .= $template->display ('articles/announce_list.tpl');
}
$template->set_var ('{LIST}', $list);
$CORE->global_template_html = str_replace ($replace, $template->display ('articles/announcement.tpl'), $CORE->global_template_html);
